package cn.com.generaldata.os.service.indicator_evaluation.composition_analysis;

import org.apache.commons.lang3.Validate;

import cn.com.generaldata.jsme_indicator_system.entity.IndicatorEvaluation;
import cn.com.generaldata.jsme_indicator_system.util.Constants;
import cn.com.generaldata.os.service.indicator_constant.ProvinceIndicatorConstant;
import cn.com.generaldata.os.service.indicator_evaluation.IndicatorEvaluationCalculateService;
import cn.com.generaldata.os.vo.IndicatorAccountVO;

/**
 * 海洋工程建筑业增加值占主要海洋产业增加值比重评估指标计算类.
 */
public class MEAICompositionCalculateService extends IndicatorEvaluationCalculateService {

	private String MEAIAddValueIndicatorName = ProvinceIndicatorConstant.MEAI_ADDVALUE_NAME;

	private String majorMarineIndustryAddValueIndicatorName = ProvinceIndicatorConstant.MAJOR_MARINE_ADDVALUE_NAME;

	@Override
	protected Double calculate(IndicatorEvaluation indicator, IndicatorAccountVO indicatorAccountVO) {
		Double result = null;
		if (indicator.getSection() == Constants.INDICATOR_LEVEL_PROVINCE) {
			result = calculateProvinceResult(indicatorAccountVO);
		} else if (indicator.getSection() == Constants.INDICATOR_LEVEL_CITY) {
			result = calculateProvinceResult(indicatorAccountVO);
		} else {
			// 县指标没确定先保留
		}
		return result;

	}

	private Double calculateProvinceResult(IndicatorAccountVO indicatorAccountVO) {
		Double MEAIAddValue = getInputOrAccountingIndicatorValue(indicatorAccountVO, indicatorAccountVO.getYear(),
				MEAIAddValueIndicatorName);
		Validate.isTrue(MEAIAddValue != null);

		Double majorMarineIndustryAddValue = getInputOrAccountingIndicatorValue(indicatorAccountVO,
				indicatorAccountVO.getYear(), majorMarineIndustryAddValueIndicatorName);
		Validate.isTrue(majorMarineIndustryAddValue != null);

		return MEAIAddValue / majorMarineIndustryAddValue * 100;
	}

}
